package 晚间练习0322;

import java.util.Arrays;
import java.util.regex.Pattern;

public class Doc12_Pattern {

    public static void main(String[] args) {
        // 1、静态校验
        boolean ret = Pattern.matches("[1-9]\\d{5,10}]", "123456");

        // 2、将一个字符串编译为正则表达式对象（Pattern对象）
        Pattern pattern = Pattern.compile(" +");
        // 3、字符串切割
        String[] array1 = pattern.split("Lily Lucy Polly Jim Tom");
        System.out.println(Arrays.toString(array1));

        // 切n-1次，生成n个子串
        String[] array2 = pattern.split("Lily Lucy Polly Jim Tom", 3);
        System.out.println(Arrays.toString(array2));
    }
}
